package com.bsoft.ecommerce.controller;

import com.bsoft.ecommerce.account.AddressInfo;
import com.bsoft.ecommerce.common.TableId;
import com.bsoft.ecommerce.service.IAddressService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "用户地址服务")
@Slf4j
@RestController
@RequestMapping("/address")
public class AddressController {
    @Autowired
    private IAddressService iAddressService;

    @ApiOperation(value = "创建",notes = "创建用户地址信息",httpMethod = "POST")
    @PostMapping("/create-address")
    public TableId createAddressInfo(@RequestBody AddressInfo addressInfo){
     return  iAddressService.createAddressInfo(addressInfo);

    }
    @ApiOperation(value = "当前用户",notes = "获取当前登录的用户地址信息",httpMethod = "GET")
    @GetMapping("/current-address")
    public  AddressInfo getCurrentAddressInfo(){
      return  iAddressService.getCurrentAddressInfo();
    }
    @ApiOperation(value = "获取当前用户地址信息",notes = "通过id 获取用户的地址信息 ",httpMethod = " GET")
    @GetMapping("address-info")
    public  AddressInfo getAddressInfoById(@RequestParam Long id){
       return  iAddressService.getAddressInfoById(id);

    }
    @ApiOperation(value = "获取用户地址信息",notes = "通过TableId 获取用户信息",httpMethod = "POST")
    public  AddressInfo getAddressInfoTableInfo(@RequestBody TableId tableId){
        return  iAddressService.getAddressInfoByTableId(tableId);
    }
}
